package org.example.demo1;

import java.util.concurrent.TimeUnit;

public class lock83 {
    public static void main(String[] args) {
        Phone3 phone2 = new Phone3();
        Phone3 phone3 = new Phone3();

        new Thread(()->{
            phone2.sendMessage();
        },"A").start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(()->{
            phone3.call();
        },"B").start();
    }
}

class Phone3{
    public static synchronized void sendMessage(){
        try {
            TimeUnit.SECONDS.sleep(4);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("sendMessage");
    }
    public static synchronized void call(){
        System.out.println("call");
    }

}
